package com.mss.media.controller;

import com.mss.media.dto.CommentsPageDTO;
import com.mss.media.service.IMediaCommentsService;
import com.mss.media.util.ResultBody;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  作品评论 前端控制器
 *  </p>
 *
 * @Author 湫
 * @Date 2021/12/30 15:12
 * Name MediaCommentsController
 */
@RestController
@CrossOrigin
@RequestMapping("/media-comments")
public class MediaCommentsController {

    @Autowired
    private IMediaCommentsService mediaCommentsService;

    /**
     * 评论分页信息
     * @param dto 筛选条件
     * @return 分页数据
     */
    @PostMapping("/find-page")
    public ResultBody findCommentsPage(@RequestBody CommentsPageDTO dto) {
        return ResultBody.success(mediaCommentsService.findCommentsPage(dto));
    }

    /**
     * 更改评论状态
     *
     * @param commentsId 评论主键
     * @param commentsStatus 状态
     * @return 状态
     */
    @GetMapping("/audit/?commentsId={commentsId}&commentsStatus={commentsStatus}")
    public ResultBody updateCommentsStatus(@PathVariable("commentsId") Long commentsId,
                                           @PathVariable("commentsStatus") Integer commentsStatus) {
        return ResultBody.success(mediaCommentsService.updateCommentsStatus(commentsId,commentsStatus));
    }
}
